home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / ANSI Headers / console.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.6 KB  |  101 lines  |  [TEXT/MMCC]

  1. /*
  2.  *    File:        console.h
  3.  *                ©1993-1995 metrowerks Inc. All rights reserved
  4.  *    Author:        Berardino E. Baratta
  5.  *
  6.  *    Content:    Interface file to ANSI console package ...
  7.  */
  8.  
  9. #ifndef __CONSOLE__
  10. #define __CONSOLE__
  11.  
  12. #pragma options align=mac68k
  13.  
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17.  
  18. /*
  19.  *    Provides an interface to allow users to set argc & argv on the Mac
  20.  */
  21. extern int ccommand(char ***);
  22.  
  23. /*
  24.  *    The following five functions provide the UI for the console package.
  25.  *    Users wishing to replace SIOUX with their own console package need
  26.  *    only provide the five functions below in a library.
  27.  */
  28.  
  29. /*
  30.  *    extern short InstallConsole(short fd);
  31.  *
  32.  *    Installs the Console package, this function will be called right
  33.  *    before any read or write to one of the standard streams.
  34.  *
  35.  *    short fd:        The stream which we are reading/writing to/from.
  36.  *    returns short:    0 no error occurred, anything else error.
  37.  */
  38.  
  39. extern short InstallConsole(short fd);
  40.  
  41. /*
  42.  *    extern void RemoveConsole(void);
  43.  *
  44.  *    Removes the console package.  It is called after all other streams
  45.  *    are closed and exit functions (installed by either atexit or _atexit)
  46.  *    have been called.  Since there is no way to recover from an error,
  47.  *    this function doesn't need to return any.
  48.  */
  49.  
  50. extern void RemoveConsole(void);
  51.  
  52. /*
  53.  *    extern long WriteCharsToConsole(char *buffer, long n);
  54.  *
  55.  *    Writes a stream of output to the Console window.  This function is
  56.  *    called by write.
  57.  *
  58.  *    char *buffer:    Pointer to the buffer to be written.
  59.  *    long n:            The length of the buffer to be written.
  60.  *    returns short:    Actual number of characters written to the stream,
  61.  *                    -1 if an error occurred.
  62.  */
  63.  
  64. extern long WriteCharsToConsole(char *buffer, long n);
  65.  
  66. /*
  67.  *    extern long ReadCharsFromConsole(char *buffer, long n);
  68.  *
  69.  *    Reads from the Console into a buffer.  This function is called by
  70.  *    read.
  71.  *
  72.  *    char *buffer:    Pointer to the buffer which will recieve the input.
  73.  *    long n:            The maximum amount of characters to be read (size of
  74.  *                    buffer).
  75.  *    returns short:    Actual number of characters read from the stream,
  76.  *                    -1 if an error occurred.
  77.  */
  78.  
  79. extern long ReadCharsFromConsole(char *buffer, long n);
  80.  
  81. /*
  82.  *    extern char *__ttyname(long fildes);
  83.  *
  84.  *    Returns the name of the terminal associated with the file id.  The unix.h
  85.  *    function ttyname calls this function (we need to map the int to a long for
  86.  *    size of int variance).
  87.  *
  88.  *    long filedes:    The file stream's id.
  89.  *    returns char *:    A pointer to the file's name (static global data)
  90.  */
  91.  
  92. extern char *__ttyname(long fildes);
  93.  
  94. #ifdef __cplusplus
  95. }    
  96. #endif
  97.  
  98. #pragma options align=reset
  99.  
  100. #endif
  101.